/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.univalle.persistencia;


import co.edu.univalle.modelo.TipoInmueble;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author Jhony
 */
@Stateless
public class TipoInmuebleDAO implements ITipoInmuebleDAO {
    
    @PersistenceContext
    private EntityManager entityManager;
    
    @Override
    public TipoInmueble consultarPorCodigo(Integer codigo) {
        try
        {
            return entityManager.find(TipoInmueble.class, codigo);            
        }
        catch(RuntimeException e){
            throw e;
        } 
    }

    @Override
    public List<TipoInmueble> consultar() {
          try
        {
            String jpql = "select t from TipoInmueble t";
            Query query = entityManager.createQuery(jpql);
            return query.getResultList();
        }
        catch(RuntimeException e){
            throw e;
        }
    }
   
}
